﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DepartmentCultureUserControl.ascx.cs"
    Inherits="JM.JCY.SharePointComponent.Department.DepartmentCulture.DepartmentCultureUserControl" %>
<script type="text/javascript">

    $(document).ready(function () {
        //ignore enter command
        $(function () {
            $("input[type=text]").keydown(function () {
                return (event.keyCode != 13);
            });
        });

        LoadDeptCul($("#<%=hfdeptIdCul.ClientID %>").val());
    });
    function LoadDeptCul(_deptId) {

        $.ajax({
            type: "GET",
            url: UserManagementServiceUrl + "GetCulture?deptId=" + _deptId,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            success: function (result) {

                var JSON = eval('(' + (result) + ')');

                $("#ttaDeptCul").val(JSON[0].deptCulture);
                $("#displayContentCul").html(JSON[0].deptCulture);

                $("#displayContentCul").show();
                $("#editContentCul").hide();

            },
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });

    }

    function UpdateDeptCul(_deptId, _input) {

        var data = _input.replace('<p>', '');
        var dataFinal = data.replace('</p>', '');
        $.ajax({
            type: "GET",
            url: UserManagementServiceUrl + "UpdateDeptCulture?deptId=" + _deptId + "&deptCulture=" + dataFinal,
            contentType: "application/json; charset=utf-8",
            dataType: 'jsonp',
            success: function (result) {


                $("#displayContentCul").html(dataFinal);

            },
            error: function (a, b, c) { alert(c); },
            failure: function (msg) {
                alert(msg);
            }
        });

    }

    function EditContentCul() {

        $("#displayContentCul").hide();
        $("#editContentCul").show();
        return false;
    }

    function SaveEditCul() {

        // update data and display
        UpdateDeptCul($("#<%=hfdeptIdCul.ClientID %>").val(), $("#ttaDeptCul").val());
        LoadDeptCul($("#<%=hfdeptIdCul.ClientID %>").val());
        $("#displayContentCul").show();
        $("#editContentCul").hide();

        return false;
    }

    function CancelEditCul() {

        $("#displayContentCul").show();
        $("#editContentCul").hide();

        return false;
    }

   
</script>
<table class="galleryHeader" width="100%">
    <tbody>
        <tr>
            <td class="style5">
                <asp:Label ID="lblDeptNameCul" runat="server"></asp:Label>&nbsp;&nbsp;-&nbsp;&nbsp;
                部门文化
            </td>
            <td align="right">
              <asp:LinkButton ID="lkbEditCulture" runat="server" Text="编辑" OnClientClick="return EditContentCul()">
                </asp:LinkButton>
            </td>
        </tr>
    </tbody>
</table>
<table>
    <tbody>
        <tr>
            <td valign="top" width="100%">
                <div id="displayContentCul">
                </div>
                <div id="editContentCul">
                    <textarea id="ttaDeptCul" name="ttaDeptCul" rows="10" cols="80" style="width: 100%"
                        class="tinymce"></textarea>
                    <table>
                        <tr>
                            <td colspan="3" class="button">
                                <asp:ImageButton ID="imgSaveCul" runat="server" ImageUrl="~/_layouts/JM.JCY.Resource/images/save.png"
                                    OnClientClick="return SaveEditCul()" />
                                <asp:ImageButton ID="imgCancelCul" runat="server" ImageUrl="~/_layouts/JM.JCY.Resource/images/cancel.png"
                                    OnClientClick="return CancelEditCul()" />
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
        </tr>
    </tbody>
</table>
<asp:HiddenField ID="hfdeptIdCul" runat="server" />
